import config from '../config/config';
import request from '../utils/request';

let service = {};


service.goods = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.goods;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}
service.getcode = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.getcode;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}
// 获取创建订单的优惠券列表
service.createlist = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.createlist;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//获取优惠券的数量
service.getcouponnum = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.getcouponnum;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}
//新人红包
service.joinactive = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.joinactive;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//获取商品分享的图片（后台处理的图片）
service.shareimg = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.shareimg;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//查看买家贝壳数量
service.getconch = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.getconch;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

// 接龙商品详情
service.solitaireGoods = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.solitaireGoods;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//接龙商品详情订单列表

service.getOrderList = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.getOrderList;
  request({
    url: requestUrl,
    showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//获取商品对应推荐好货（关联推荐商品）
service.getRecommend = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.getRecommend;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//检测商品是否为限购商品
service.purchase = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.purchase;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}

//获取砍价订单详情
service.getOrderDetail = (param, cb) => {
  param = param || {};

  let requestUrl = config.api.getOrderDetail;
  request({
    url: requestUrl,
    // showLoading: true,
    data: param,
    method: 'GET',
    success: res => {
      cb(res);
    },
    fail: res => {
      // cb(res);
    }
  });
}


module.exports = service;